Skip to content

Conversation

rucpande
Copy link
Contributor

@rucpande rucpande commented Oct 1, 2025

Description

Add support for Cisco AI Defense Security, Privacy, and Safety guardrails as a third party API.

Features

  • Input Protection: Inspect user prompts before processing
  • Output Protection: Inspect bot responses before delivery
  • Configuration: Environment-based API configuration
  • Rails Exceptions: Support for enable_rails_exceptions mode
  • Logging: Logging for debugging and monitoring

Related Issue(s)

Checklist

  • I've read the CONTRIBUTING guidelines.
  • I've updated the documentation if applicable.
  • I've added tests if applicable.
  • @cparisien thanks for reviewing!

Integration Test Output:

NeMoGuardrails_Integration_2

- Add AI Defense action for input/output protection
- Add documentation for setup and configuration
- Support for environment-based API key configuration

Fixes NVIDIA-NeMo#1420
Copy link
Contributor

github-actions bot commented Oct 1, 2025

Documentation preview

https://nvidia-nemo.github.io/Guardrails/review/pr-1433

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2025

Codecov Report

❌ Patch coverage is 95.12195% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nemoguardrails/rails/llm/config.py 62.50% 3 Missing ⚠️
nemoguardrails/library/ai_defense/actions.py 98.64% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Pouyanpi Pouyanpi requested a review from Copilot October 2, 2025 13:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Cisco AI Defense integration to NeMo Guardrails, providing security guardrails for input and output protection. The integration enables inspection of user prompts and bot responses through Cisco's AI Defense API to detect and block potentially harmful content.

Key changes:

  • Implementation of AI Defense inspection actions and flows for input/output protection
  • Configuration support through environment variables (API key and endpoint)
  • Comprehensive test coverage including unit, integration, and error handling tests

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
nemoguardrails/library/ai_defense/actions.py Core AI Defense inspection action with HTTP client for API calls
nemoguardrails/library/ai_defense/flows.v1.co Colang v1.0 flow definitions for input/output protection
nemoguardrails/library/ai_defense/flows.co Colang v2.0 flow definitions for input/output protection
tests/test_ai_defense.py Comprehensive test suite covering unit, integration, and error scenarios
docs/user-guides/community/ai-defense.md User documentation for setup and usage
docs/user-guides/guardrails-library.md Integration into main guardrails library documentation
examples/configs/ai_defense/config.yml Example configuration file
examples/configs/ai_defense/README.md Example documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Remove placeholder comment in test_real_api_call_with_safe_output
- Remove debug print statements from test code
- Fix incorrect docstring in ai_defense_text_mapping function~
Copy link
Collaborator

@tgasser-nv tgasser-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Mostly naming nits to address.

Could you also run a local integration test (pytest -m integration) with AI_DEFENSE_API_ENDPOINT and AI_DEFENSE_API_KEY set and copy the result into the description?

Copy link
Collaborator

@Pouyanpi Pouyanpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rucpande for your PR, it looks good to me 👍🏻

@rucpande rucpande force-pushed the feature/cisco-ai-defense-integration-1420 branch from 3bcbdca to 8c53797 Compare October 13, 2025 15:50
@rucpande
Copy link
Contributor Author

Thank you for your reviews and the collboration @Pouyanpi and @tgasser-nv. Appreciate it!

@Pouyanpi Pouyanpi merged commit 81e7c0b into NVIDIA-NeMo:develop Oct 16, 2025
8 checks passed
@Pouyanpi Pouyanpi added this to the v0.18.0 milestone Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Add support for Cisco AI Defense API as a guardrail provider for both input (prompt) and output (response) protection in NeMo Guardrails.

4 participants